package examples;

import search.*;
/**
 * Write a description of class FindRouteVisitor here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class FindRouteVisitor extends DepthFirstSearchVisitor<City,Road>
{
    private CityMap map;
    private City start;
    private City goal;
    
    public FindRouteVisitor(CityMap map, String startCityName, String endCityName)
    {
        this.map = map;
        start = findCity(startCityName);
        goal = findCity(endCityName);
    }
    
    public City getStart()
    {
        return start;
    }
    
    public City findCity(String name)
    {
        for (City c : map.getNodes()) {
            if (c.getData().equals(name)) {
                return c;
            }
        }
        return null;
    }
    
    public boolean isGoal(City c)
    {
        return c.equals(goal);
    }
    
}
